package com.qf.controller;

import com.qf.entity.*;
import com.qf.feign.CityFeign;
import com.qf.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService searchService;
    @Autowired
    private CityFeign cityFeign;

    @RequestMapping("/insertHotal")
    public R<Boolean> syncHotal(@RequestBody Hotal hotal){
        searchService.insertHotal(hotal);
        return new R<Boolean>().setData(true);
    }
    @RequestMapping("/insertRoom")
    public R<Boolean> syncHotalRoom(@RequestBody Room room){
        boolean flag = searchService.insertRoom(room);
        return new R<Boolean>().setData(flag);
    }
    @RequestMapping("/insertRoomPrice")
    public R<Boolean> syncHotalRoomPrices(@RequestParam Integer hid, @RequestBody List<RoomPrice> priceList){
        int flag = searchService.insertRoomPrice(hid, priceList);
        return new R<Boolean>().setData(true);
    }
    @RequestMapping("/updateRoomPrice")
    public R<Boolean> updateHotalRoomPrice(@RequestParam Integer hid,@RequestBody RoomPrice roomPrice){
        int flag = searchService.updateRoomPrice(hid, roomPrice);
        return new R<Boolean>().setData(true);
    }
}
